package com.qf.controller;

import com.qf.entity.Medicineii;
import com.qf.pojo.BaseResult;
import com.qf.service.MedicineService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

@RestController
@RequestMapping("/medicine")
@CrossOrigin
public class MedicineController {

    @Autowired
    MedicineService medicineService;

    @GetMapping("/findAllMedicineInfo")
    public BaseResult findAllMedicineInfo(@RequestParam("page")Integer page, @RequestParam("size")Integer size, @RequestParam("name")String name){
        BaseResult allMedicineInfo = medicineService.findAllMedicineInfo(page,size,name);
        return allMedicineInfo;
    }
    @GetMapping("/findByIdMedicine")
    public BaseResult findByIdMedicine(@RequestParam(value="midi")Integer midi){
        BaseResult byIdMedicine = medicineService.findByIdMedicine(midi);
        return byIdMedicine;
    }

    @PostMapping("/addMedicine")
    public BaseResult addMedicine(@RequestBody Medicineii medicineii){
        BaseResult result = medicineService.addMedicine(medicineii);
        return result;
    }
    @PutMapping("/updateMedicine")
    public BaseResult updateMedicine(@RequestBody Medicineii medicineii){
        BaseResult result = medicineService.updateMedicine(medicineii);
        return result;
    }
    @DeleteMapping("/deleteMedicineById/{midii}")
    public BaseResult deleteMedicineById(@PathVariable("midii") Integer midii){
        BaseResult result = medicineService.deleteMedicineById(midii);
        return result;
    }

}
